package com.wn.consumer.consumer3;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author yellow Docter
 * @date 2022 -08-31
 * @desc
 */
@Component
@Slf4j
public class LogConsumer {


    /**
     * 把队列和 交换机进行绑定
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "queue-direct-log"),             //队列
            exchange = @Exchange(
                    name = "direct-log",
                    type = ExchangeTypes.DIRECT   //DIRECT 交换机
            ),
            key = {     //如果路由是 下面的三个 都是 当前的 log消费者进行消费
                  "info",
                  "error",
                  "warn"
            }                        //路由 （决定交换机中的消息到那个队列中）
    ))
    public void errorConsumer(String msg) {

        log.info("============>log消费者收到的消息是:{}",msg);

    }
    
}
